import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import HomeView from '../views/home/HomeView.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    //判断是否需要底部栏
    meta: {
      tabbrashow: true
    },
    beforeEnter(to, form, next) {
      if (localStorage.getItem("userId") && localStorage.getItem("authToken") != '') {
        next()
      } else {
        next("/login")
      }
    }
  },

  {
    path: '/about',
    name: 'about',
    component: () => import('../views/my/AboutView.vue'),
    meta: {
      tabbrashow: true
    }
  },
  // 动火方案
  {
    path: '/newscheme',
    component: () => import('../views/New-scheme/NewScheme.vue'),
    meta: {
      tabbrashow: false
    }
  },
  // 动火方案详情
  {
    path: '/details',
    component: () => import('../views/detail/DetailPage.vue'),
    meta: {
      tabbrashow: false
    }
  },
  // 退出登录
  {
    path: '/quit',
    component: () => import('../views/quit/index.vue'),
    meta: {
      tabbrashow: false
    }
  },
  {
    path: '/login',
    component: () => import('../views/login/LoginPage.vue'),
    meta: {
      tabbrashow: false
    }
  },


]
const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
